﻿<!--#include file="conn.asp"-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>武汉理工大学计算机协会维修预约系统</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    <script type="text/javascript" src="MyString.js"></script>

    <script type="text/javascript" src="XmlObject.js"></script>

    <script type="text/javascript" src="/js/jquery-1.10.2.min.js"></script>

    <link rel="stylesheet" type="text/css" href="default.css" />

    <script language="JavaScript" type="text/javascript">
        function checkInput() {
            var sdName = sName.value;
            var sdPhone = sPhone.value; //50
            var sdPlace = sPlace.value; //
            var sdSex = sex[sex.selectedIndex].value; //10
            var sdQueryCode = querycode.value;
            var sdDescribe = describe.value;
            if (sdDescribe.length <= 0) {
                setMessage("系统提示", "请填写故障或需求详情", function() { });
                return false; 
             }
            if (checkLength(sdName, 50) == false) return false;
            if (checkLength(sdPhone, 50) == false) return false;
            if (checkLength(sdSex, 10) == false) return false;
            if (checkLength(sdName, 50) == false) return false;
        }
        function onSubmitClick() {
            if (checkInput()==false) return false;
            var sdName = sName.value;
            var sdPhone = sPhone.value; //50
            var sdPlace = sPlace.value; //
            var sdSex = sex[sex.selectedIndex].value; //10
            var sdQueryCode = querycode.value;
            var sdDescribe = describe.value;
            $.ajax({
                url: "thj.asp",
                data: {
                    Action: "new",
                    Name: sdName,
                    Phone: sdPhone,
                    Place: sdPlace,
                    Sex: sdSex,
                    QueryCode: sdQueryCode,
                    Describe: sdDescribe
                },
                success: function(data) {
                    var oData = eval("(" + data + ");");
                    if (oData.msg == 'ok') {
                        query_code.innerHTML = '<b>' + oData.code + '</b>';
                        fullmask.style.display = "block";
                        message.style.display = "block";
                    }
                    else {
                        alert("出现未知错误，请稍后重试！");
                    }
                }
            });
        }
        function checkLength(sText, nLenLimit) {
            if (sText.length > nLenLimit) return false;
            return true;
        }
        window.onload = function() {
            message.style.display = "none";
            fullmask.style.display = "none";
        }
        function closeDiv() {
            message.style.display = "none";
            window.location = "index.asp"
            return true;
        }
        function closeThisDiv() {
            PublicMsg.style.display = "none";
            return true;
        }
        function acceptRqt(nID) {
            $.ajax({
                url: "thj.asp",
                data: {
                    Action: "accept",
                    RequestID: nID
                },
                success: function(data) {
                    var oData = eval("(" + data + ");");
                    if (oData.msg == 'ok') {
                        setMessage("项目承接概况",
                        "同学姓名：<b>" + oData.name + "</b><br />" +
                        "&nbsp;&nbsp;&nbsp;&nbsp;联系电话：<b>" + oData.telphone + "</b><br />" +
                        "&nbsp;&nbsp;&nbsp;&nbsp;联系地址：<b>" + oData.location + "</b><br />" +
                        "&nbsp;&nbsp;&nbsp;&nbsp;故障描述：<b>" + oData.describe + "</b>"
                        , function() {
                            window.location = "index.asp";
                        });
                    }
                    else {
                        alert(oData.param);
                    }
                }
            });
        }
        var afterFunction;
        function setMessage(sTitle, sContent, afterClose) {
            p_msg_title.innerHTML = sTitle;
            p_msg_area.innerHTML = sContent;
            PublicMsg.style.display = "block";
            afterFunction = afterClose;
        }
        function closeMessage() {
            PublicMsg.style.display = "none";
            debugger;
            afterFunction();
            return true;
        }
        function denyRqt(sID) {
            $.ajax({
                url: "thj.asp",
                data: {
                    Action: "refuse",
                    rid: sID
                },
                success: function(data) {
                    var oData = eval("(" + data + ");");
                    if (oData.msg == 'ok') {
                        setMessage("请求执行结果成功",
                        "返回结果：<b>" + oData.param + "</b>"
                        , function() {
                            parent.window.location = parent.window.location;
                        });
                    }
                    else {
                        setMessage("请求执行结果失败",
                        "返回结果：<b>执行失败！</b>"
                        , function() {
                            parent.window.location = parent.window.location;
                        });
                    }
                }
            });
        }
    </script>

</head>
<body>
    <div class="fulldiv" id="fullmask">
    </div>
    <div class="msgdiv" id="message">
        <span class="msg_title" id="msg_title">提交成功</span><span class="close_text" onclick="return closeDiv();">
            <a href="javascript:void(0);">[关闭]</a></span> <span class="msg_content" id="msg_area">
                恭喜你，维修维护咨询申请已提交
                <p>
                    你的申请流水号为：<span id="query_code"></span>
                    <p>
                你的查询密码请自己记住了。 </span>
    </div>
    <div class="msgdiv" id="PublicMsg">
        <span class="msg_title" id="p_msg_title"></span><span class="close_text" onclick="return closeMessage();">
            <a href="javascript:void(0);">[关闭]</a> </span><span class="msg_content" id="p_msg_area">
            </span>
    </div>
    <%if adminLogin=true or officerLogin=true then %>
    <div class="topfloat">
        <a href="mylist.asp" class="btnClass">我承接的任务<%if getUndoneNum>0 then %><span style="color: Red;
            font-size: 13px;">[<%=getUndoneNum %>]</span><%end if %></a>
    </div>
    <%end if %>
    <div>
        <div style="text-align: center; width: 100%;font-weight:bold;">
            欢迎使用武汉理工大学计算机协会电脑维护支持预约系统 [ <span class="login">
                <%if Session("fix_loginrole")="admin" or Session("fix_loginrole")="officer" then %>
                <a href="login.asp?Action=logout">退出登陆</a>
                <a href="alterinfo.asp">更改信息</a>
                <%else %>
                <a href="login.asp">登陆</a>
                <%end if %>
            </span>| <span class="login"><a href="query.asp">查询</a></span> ]<br />
        </div>
        使用须知：<br />
        1、系统将会保存你的姓名，性别，联系电话，故障描述等基本信息；<br />
        2、协会的干事将会看到你的基本信息，但是只有干事才能看到；<br />
        3、除非国家要求，法律规定的情况，我们不向任何个人或者组织提供你的信息（其实学校那你的信息多得多）；<br />
        4、电脑维护服务结束后，信息仍将保留，用作效果考评及协会工作调研；<br />
        <br />
        <table style="width: 100%;">
            <tr>
                <td>
                    <b>申请电脑维护：
                        <br />
                        <table class="table_style">
                            <tr row-type="data">
                                <td align="center" colspan="2">
                                    申请信息
                                </td>
                            </tr>
                            <tr row-type="data">
                                <td style="width: 90px;">
                                    姓名
                                </td>
                                <td>
                                    <input class="text_input" issave="true" fromvalue="true" type="text" id="sName" name="fname" />
                                </td>
                            </tr>
                            <tr row-type="data">
                                <td style="width: 90px;">
                                    性别
                                </td>
                                <td name="sex">
                                    <select issave="true" class="text_input" id="sex" name="fsex">
                                        <option selected value="girl">女</option>
                                        <option value="boy">男</option>
                                    </select>
                                </td>
                            </tr>
                            <tr row-type="data">
                                <td style="width: 90px;">
                                    联系电话
                                </td>
                                <td>
                                    <input class="text_input" issave="true" fromvalue="true" id="sPhone" type="text"
                                        name="fphone" />
                                </td>
                            </tr>
                            <tr row-type="data">
                                <td style="width: 90px;">
                                    你的位置
                                </td>
                                <td>
                                    <input class="text_input" issave="true" fromvalue="true" id="sPlace" type="text"
                                        name="fplace" />
                                </td>
                            </tr>
                            <tr row-type="data">
                                <td style="width: 90px;">
                                    故障描述
                                </td>
                                <td>
                                    <textarea class="text_area" id="describe" name="fdescribe"></textarea>
                                </td>
                            </tr>
                            <tr row-type="data">
                                <td style="width: 90px;">
                                    查询密码
                                </td>
                                <td>
                                    <input class="text_input" issave="true" fromvalue="true" id="querycode" name="fquerycode"
                                        type="text" />
                                </td>
                            </tr>
                            <tr>
                                <td style="text-align: center" colspan="2">
                                    <input type="button" value="提交申请" onclick="return onSubmitClick();" />
                                </td>
                            </tr>
                        </table>
                        说明：
                        <br />
                        1、查询密码是用于查询维修申请的处理状态时的身份验证，由<b>你自己</b>设定；<br />
                        2、提交后会有一个受理单号，这个单号由<b>系统生成</b>，用于查询申请的处理状态。
                </td>
            </tr>
            <tr>
                <td>
                    <%if Session("fix_loginrole")="admin" or Session("fix_loginrole")="officer" then%>
                    <b>已提交的求助：</b><br />
                    <br />
                    <%
                        dim r
                        set r=server.CreateObject("adodb.recordset")
                        r.open "select top 20 * from s_request left join s_accept on s_accept.RequestID=s_request.id order by s_request.id desc",conn,3,3
                            if r.recordcount>0 then
                                do while not r.eof = true
                    %>
                    <table class="table_style">
                        <tr row-type="data">
                            <td align="center" colspan="2">
                                申请信息
                                <%if r("resp_boycode")=Session("fix_usercode") then %>
                                <span style="color: Red; font-size: 14px; font-weight: bold;">[我接的]</span>
                                <%end if %>
                            </td>
                        </tr>
                        <tr row-type="data">
                            <td style="width: 90px;">
                                姓名
                            </td>
                            <td>
                                <%=r("sName")%>
                            </td>
                        </tr>
                        <tr row-type="data">
                            <td style="width: 90px;">
                                性别
                            </td>
                            <td name="sex">
                                <%=r("sex") %>
                            </td>
                        </tr>
                        <tr row-type="data">
                            <td style="width: 90px;">
                                联系电话
                            </td>
                            <td>
                                <%=r("sPhone") %>
                            </td>
                        </tr>
                        <tr row-type="data">
                            <td style="width: 90px;">
                                你的位置
                            </td>
                            <td>
                                <%=r("sPlace") %>
                            </td>
                        </tr>
                        <tr row-type="data">
                            <td style="width: 90px;">
                                故障描述
                            </td>
                            <td>
                                <textarea class="text_area" id="Textarea1" name="fdescribe" readonly><%=r("describe") %></textarea>
                            </td>
                        </tr>
                        <tr row-type="action">
                            <td style="width: 90px;">
                                处理此请求
                            </td>
                            <td>
                                <%if r("state")="wait" then %>
                                <%if adminLogin=true then %>
                                <input type="button" onclick="denyRqt('<%=r("s_request.id") %>');" value="拒绝请求" />
                                <%end if %>
                                <input type="button" onclick="acceptRqt('<%=r("s_request.id") %>');" value="承接请求" />
                                <%else %>
                                <b style="color: Red;">[<%=TransState(r("state"))%>]</b>
                                <%end if %>
                            </td>
                        </tr>
                        <br />
                    </table>
                    <%
                            r.movenext
                            loop
                            r.close
                          end if
                    %>
                    <%end if %>
                </td>
            </tr>
        </table>
    </div>
    <%if adminLogin=true or officerLogin=true then %>
    <div class="makeup">
    </div>
    <%end if %>
</body>
</html>